package com.jt.springboot_demo01.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/*将该类交给spring容器进行管理,
2,SpringMVC负责调用该对象接收用户的请求,
3,将业务处理之后,为页面韩慧json数据
4.Responsebody作用:将数据转换为JSON串*/
@RestController
@PropertySource(value = "classpath:/mysqls.properties",encoding = "UTF-8")
public class JDBCController {
    @Value("${mysql.username}")//sper表达式,从spring容器内部获取key动态为属性赋值
    String username;
    @Value("${mysql.password}")
    String password;
    @RequestMapping("/getMsg")
    public String getMsg(){

        return "你好数据库"+username+password;
    }

    @Value("${mysql.username2}")//sper表达式,从spring容器内部获取key动态为属性赋值
            private String username2;
    @Value("${mysql.password2}")
    private String password2;
    @RequestMapping("/getMsg2")
    public String getMsg2(){

        return "你好数据库"+username2+password2;
    }
}
